//
//  MainViewController.m
//  XYFMApp
//
//  Created by 岁变 on 16/8/27.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "XYMacro.h"

@interface MainViewController ()

@end

@implementation MainViewController


- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
        self.tabBar.barTintColor = [UIColor colorWithRed:0.94 green:0.00 blue:0.00 alpha:1.00];
        self.tabBar.translucent = NO;
        self.viewControllers = [self configRootTabBarControllers];
        
        
    }
    return self;
}

- (NSArray <UIViewController *> *)configRootTabBarControllers {
    
    NSMutableArray *mArr = [NSMutableArray array];
    
    
    VCOfDiscover *vcOfDiscover = [[VCOfDiscover alloc] init];
    BaseNavigationController *naviDiscover = [[BaseNavigationController alloc] initWithRootViewController:vcOfDiscover];
    naviDiscover.tabBarItem = [[UITabBarItem alloc] init];
    naviDiscover.tabBarItem.image = [[UIImage imageNamed:@"menu_icon_1_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviDiscover.tabBarItem.selectedImage = [[UIImage imageNamed:@"menu_icon_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviDiscover.tabBarItem.title = @"发现";
    [mArr addObject:naviDiscover];
    
    VCOfLoveListen *vcOfLoveListen = [[VCOfLoveListen alloc] init];
    BaseNavigationController *naviLoveListen = [[BaseNavigationController alloc] initWithRootViewController:vcOfLoveListen];
    naviLoveListen.tabBarItem = [[UITabBarItem alloc] init];
    naviLoveListen.tabBarItem.image = [[UIImage imageNamed:@"menu_icon_3_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviLoveListen.tabBarItem.selectedImage = [[UIImage imageNamed:@"menu_icon_3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviLoveListen.tabBarItem.title = @"爱听";
    [mArr addObject:naviLoveListen];
    
    VCOfSocial *vcOfSocial = [[VCOfSocial alloc] init];
    BaseNavigationController *naviOfSocial = [[BaseNavigationController alloc] initWithRootViewController:vcOfSocial];
    naviOfSocial.tabBarItem.image = [[UIImage imageNamed:@"menu_icon_2_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviOfSocial.tabBarItem.selectedImage = [[UIImage imageNamed:@"menu_icon_2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    naviOfSocial.tabBarItem.title = @"社交";
    [mArr addObject:naviOfSocial];
    
    VCOfMine *vcOfMine = [[VCOfMine alloc] init];
    VCOfRegisterThird *vcOfMainPage = [[VCOfRegisterThird alloc] init];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    if (![user objectForKey:@"password"]) {
        BaseNavigationController *naviOfMine = [[BaseNavigationController alloc] initWithRootViewController:vcOfMine];
        naviOfMine.tabBarItem.image = [[UIImage imageNamed:@"menu_icon_0_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        naviOfMine.tabBarItem.selectedImage = [[UIImage imageNamed:@"menu_icon_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        naviOfMine.title = @"我的";
        [mArr addObject:naviOfMine];
    } else {
        BaseNavigationController *naviOfMine = [[BaseNavigationController alloc] initWithRootViewController:vcOfMainPage];
        naviOfMine.tabBarItem.image = [[UIImage imageNamed:@"menu_icon_0_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        naviOfMine.tabBarItem.selectedImage = [[UIImage imageNamed:@"menu_icon_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        naviOfMine.title = @"我的";
        [mArr addObject:naviOfMine];
    }
    
    return mArr;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
